<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="shortcut icon" href="<!--{eval echo register_static('img/touch-icon-57x57.png');}-->">
    <title>粉粉管理系统</title>

    <!-- Bootstrap core CSS -->
    <link href="<!--{eval echo register_static('css/bootstrap.min.css');}-->" rel="stylesheet">

    <link href="<!--{eval echo register_static('css/bootstrap-reset.css');}-->" rel="stylesheet">
    <!--Animation css-->
    <link href="<!--{eval echo register_static('css/animate.css');}-->" rel="stylesheet">
    <!--Icon-fonts css-->
    <link href="<!--{eval echo register_static('assets/font-awesome/css/font-awesome.css');}-->" rel="stylesheet" />
    <link href="<!--{eval echo register_static('assets/ionicon/css/ionicons.min.css');}-->" rel="stylesheet" />
    <link href="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.css');}-->" rel="stylesheet">
    <!-- Plugins css -->
    <link href="<!--{eval echo register_static('assets/modal-effect/css/component.css');}-->" rel="stylesheet">
    <!-- DataTables -->
    <link rel="stylesheet" href="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.css" rel="stylesheet');}-->" />
    <!-- Custom styles for this template -->
    <link href="<!--{eval echo register_static('css/style.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('css/helper.css');}-->" rel="stylesheet">
    <!-- My styles for this template -->
    <link href="<!--{eval echo register_static('css/common.css');}-->" rel="stylesheet"></head>

<body>

<!-- Aside Start-->
<!--{template admin_v2/leftside}-->
<!-- Aside Ends-->

<!--Main Content Start -->
<section class="content">

    <!-- Header -->
    <!--{template admin_v2/header}-->
    <!-- Header Ends -->

    <!-- Page Content Start -->
    <!-- ================== -->

    <div class="wraper container-fluid user-list">

        <div class="row">
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">增加靓号</h3>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-4 col-sm-4 col-xs-4">
                                <div class="form-inline" role="form">
                                    <div class="form-group m-l-10">
                                    <button type="button" id="addBtn"  class="btn btn-success m-l-10">新增</button>
                                </div>
                            </div>
                        </div>
                        <br/>
                        <div class="row" id="tbody_list">

                        </div>

                    </div>
                </div>
            </div>
        </div>

    </div>
    </div>
    </section>
    <!-- Footer Start -->
    <!--{template admin_v2/footer}-->
    <!-- Footer Ends -->
<!-- Main Content Ends -->

<!-- js placed at the end of the document so the pages load faster -->
<script src="<!--{eval echo register_static('js/jquery.js');}-->"></script>
<script src="<!--{eval echo register_static('js/bootstrap.min.js');}-->"></script>

<script src="<!--{eval echo register_static('js/pace.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/wow.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/jquery.nicescroll.js');}-->" type="text/javascript"></script>

<script src="<!--{eval echo register_static('js/jquery.app.js');}-->"></script>

<script src="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/datatables/dataTables.bootstrap.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.init.js');}-->"></script>

<!-- Modal-Effect -->
<script src="<!--{eval echo register_static('assets/modal-effect/js/classie.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/modal-effect/js/modalEffects.js');}-->"></script>

<!--layui-->
<script src="<!--{eval echo register_static('layer/layer.js');}-->"></script>
<script src="<!--{eval echo register_static('laytpl/laytpl.js');}-->"></script>

<script type="text/html" id="addTpl">
    <form role="form">
        <div class="form-group">
            <label for="UID">UID</label>
            <input type="text" class="form-control" id="uid" placeholder="靓号UID">
        </div>
        <div class="form-group">
            <label for="account">账号</label>
            <input type="text" class="form-control" id="account" placeholder="账号">
        </div>
        <div class="form-group">
            <label for="password">密码</label>
            <input type="text" class="form-control" id="password" placeholder="密码">
        </div>
    </form>
    <button type="button" id="addData" class="btn btn-success">添加</button>
</script>
<script type="application/javascript">
    $(document).ready(function() {
        // 设置table配置
        $('#datatable').dataTable({
            "iDisplayLength": 50,
            "aLengthMenu": [10, 20, 50, 100],
            "searching": false,
            "bLengthChange": false,
            "bSort": false,
            "bPaginate": false
        });
        $.fn.serializeObject = function(){
            var o = {};
            var a = this.serializeArray();
            $.each(a, function() {
                if (o[this.name] !== undefined) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        };
        $(document).on('click','#addBtn',function () {
            var tpl = laytpl($('#addTpl').html());
            tpl.render({},function (html) {
                layer.open({
                    type: 1,
                    skin: 'layui-layer-demo', //样式类名
                    closeBtn: 1, //不显示关闭按钮
                    anim: 2,
                    area: ['600px','400px;'],
                    shadeClose: false, //开启遮罩关闭
                    content: html
                });
            })
        });
        $(document).on('click','#addData',function () {
            var data = {uid:$('#uid').val(),account:$('#account').val(),password:$('#password').val(),action:'addGoodAccount'};
            request(data,function (res) {
                if(res.result){
                    layer.alert('操作成功!');
                }else{
                    var str = '操作失败';
                   if(res['_code']=='AGA001'){
                       str = '靓号不存在';
                   }else if (res['_code']=='AGA002'){
                       str = "账号已经存在";
                   }else if(res['_code']=='AGA003'){
                       str = "靓号已启用";
                   }
                    layer.alert(str);
                }
            });
        });
        var request = function(data, func, method, url){
            layer.load();
            url    ? url    : url    = 'admin.php?ac=admin';
            method ? method : method = 'GET';
            data['do'] = 'goodAccount';
            data['op'] = 'start';
            $.ajax({
                dataType : 'json',
                url  : url,
                type : method,
                data : data,
                success: function(returnData){
                    layer.closeAll();
                    func(returnData);
                }
            });
        }
    });

</script>
</body>
</html>